package com.github.pig.admin.service.impl;

import com.github.pig.admin.mapper.SysDeptMapper;
import com.github.pig.admin.mapper.SysRoleMapper;
import com.github.pig.admin.model.SysDept;
import com.github.pig.admin.service.SysDeptService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;

@Service
public class SysDeptServiceImpl implements SysDeptService {
	
	@Autowired
	SysDeptMapper lrdOrgMapper;
	
	@Autowired
	SysRoleMapper lrdRoleMapper;

	@Override
	public Map<String,Object> queryUserOrg(Map<String,Object> map) {
		return lrdOrgMapper.queryUserOrg(map);
	}
	@Override
	public String getChilds(String orgCd) {
		List<Map<String, Object>> list = lrdOrgMapper.getChilds(orgCd);
		StringBuffer sb = new StringBuffer();
		for (Map<String, Object> map2 : list) {
			sb.append(map2.get("childIds"));
			sb.append(",");
		}
		if(StringUtils.isNotBlank(sb)) {
			sb.deleteCharAt(sb.length() - 1);
		}
		return sb.toString();
	}
	@Override
	public List<String> getChildList(String orgCd) {
		return lrdOrgMapper.getChildList(orgCd);
	}
	
}
